package com.kkb.spring06.aop;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspect2 {


    public void before01(JoinPoint joinPoint){//joinPoint指代要处理的目标对象的方法
        System.out.println("前置通知：在目标对象方法执行之前执行：");
    }

    public void afterReturning(Object result){
        System.out.println("后置通知，获得目标对象方法的返回值");
        System.out.println(result);
    }

    public void afterThrowing(JoinPoint joinPoint,Throwable ex){
        System.out.println(joinPoint.getSignature()+"方法抛出异常");
        System.out.println(ex.getMessage());
    }

    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
        System.out.println("环绕通知----------------------------------------目标对象方法执行之前");
//执行目标对象的方法
        Object result = proceedingJoinPoint.proceed();
        System.out.println("环绕通知----------------------------------------目标对象方法执行之后");
        return result+"，柳传志";
    }


    public void after(){
        System.out.println("最后被执行的部分");
    }
}
